package com.czxy.demo04;

/**
 * Created by hp on 2020/2/1.
 */
public class Test19 {
    public static void main(String[] args) {
        BankCard b = new BankCard(7000.0);
        try {
            drawMoney(3000,b);
        }catch (BankException e){
            e.printStackTrace();
        }
        try {
            saveMoney(6000,b);
        }catch (BankException e){
            e.printStackTrace();
        }
    }
    public static void saveMoney(double money,BankCard b)throws BankException{
        if (money>5000){
            throw new BankException("大哥能不能少存点，这一下我算不过来。");
        }else {
            b.setBalance(b.getBalance()+money);
            System.out.println("您现在的存款为"+b.getBalance());
        }
    }
    public static void drawMoney(double money,BankCard b) throws BankException{
        if (money>b.getBalance()){
            throw new BankException("大哥没那么钱，咱别来装了。");
        }else {
            b.setBalance(b.getBalance()-money);
        }
        System.out.println("取出"+money+"钱,还剩"+b.getBalance()+"钱。");
    }
}
